package com.lwq.commentTool.service;

import com.lwq.commentTool.model.CookBlockModel;
import com.lwq.commentTool.model.CookItemModel;
import com.lwq.commentTool.model.CookModel;
import com.lwq.commentTool.model.EditInformModel;
import com.lwq.commentTool.model.EditItemInformModel;
import com.lwq.commentTool.util.GsonUtil;

public class EditInformService {
	public static EditInformService instance = null;
	private CookModel mCookModel = null; 
	public EditInformService(){
//		makeCookData("res/data.json");
		mCookModel = getCookModel("res/data.json");
	}
	
	public static EditInformService getInstance(){
		if(instance == null){
			instance = new EditInformService();
		}
		return instance;
	}
	
	public CookModel getCookModel(String path){
		CookModel model = null;
		if(path == null) return model;
		model = GsonUtil.FileToModel(path, CookModel.class);
		return model;
	}
	
	public void makeCookData(String path){
		CookModel model = null;
		CookBlockModel block = null;
		CookItemModel item = null;
		if(path == null) return;
		model = new CookModel();
		block = new CookBlockModel();
		item = new CookItemModel();
		block.getBlock().put("title1", item);
		model.getDatas().put("time", block);
		GsonUtil.modelToFile(model, path);
	}
	
	public EditInformModel getEditInformModel(){
		EditInformModel model = GsonUtil.FileToModel("res/editinfo_cn.json", EditInformModel.class);
		return model;
	}
	
	public String getProccString(EditInformModel model){
		String randText = null;
		if(mCookModel != null){
			randText = mCookModel.getRandomText("good");
		}
		return randText;
	}
}
